# -*- coding:utf-8 -*-
class Solution:
    # s, pattern都是字符串
    def match(self, s, pattern):
        # write code here
        l =  len(s)
        p = len(pattern)
        if l==0 and p==0:
            return True
        if l!=0 and p==0:
            return False
        if p>1 and pattern[1] == '*':
            if l>0 and (s[0] == pattern[0] or pattern[0]=='.'):
                return self.match(s[1:],pattern) or self.match(s[1:],pattern[2:])or self.match(s,pattern[2:])
            else:
                return self.match(s,pattern[2:])
        if l>0 and (s[0] == pattern[0] or pattern[0]=='.'):
            return self.match(s[1:],pattern[1:])
        return False


s = Solution()
print(s.match('aaa', 'a*a'))
